<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<title>在线用户管理</title>
		<script type="text/javascript" src="../../js/boot.js"></script>
	</head>

	<body>
		<div style="width:100%;">
			<fieldset id="fd1" style="width: 97%; margin-bottom: 4px;">
				<legend><span>查询条件</span></legend>
				<div id="queryForm" class="fieldset-body">
					<table class="form-table" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td class="form-label">
								<span>用户姓名：</span>
								<input name="projectName" class="mini-textbox" style="width: 150px" />
								<input name="projectName_link" value="like" class="mini-hidden" style="width: 150px" />
								<a class="mini-button" onclick="doSearch">查询</a>
								<a class="mini-button" onclick="doRemove">删除</a>
							</td>
						</tr>
					</table>
				</div>
			</fieldset>

		</div>
		<div style="width:100%;height:86%;">
			<div class="mini-fit">
				<div id="datagrid" class="mini-datagrid" style="width:100%;height:100%;" pageSize="20" idField="instID" allowResize="true">
				</div>
			</div>
		</div>

	</body>

	<script type="text/javascript">
		miniInit();
		var queryForm = new mini.Form("#queryForm");

		var datagrid = mini.get("datagrid");
		datagrid.set({
			columns: [{
					type: "indexcolumn"
				},
				{
					field: "key",
					width: 0,
					headerAlign: "center",
					header: "主键"
				},
				{
					field: "userName",
					width: 160,
					headerAlign: "center",
					header: "姓名"
				},
				{
					field: "lastLoginTime",
					width: 80,
					headerAlign: "center",
					header: "最近登录时间",
					dateFormat: "yyyy-MM-dd HH:mm:ss"
				}
			]
		});

		doSearch();

		function doSearch() {
			var data = queryForm.getData(true, false);
			http.get("/online/allUsers.do", function(page) {
				if(page.success) {
					var list = page.data;
					datagrid.setData(list);
				} else {
					mini.alert("错误", page.message, null);
				}
			});
		}

		function doRemove() {
			if(datagrid.getSelected()) {
				var row = datagrid.getSelected();
				http.post("/online/removeUser.do", row, function(page) {
					if(page.success) {
						console.log(row);
						datagrid.removeRow(row);
					} else {
						mini.alert("错误", page.message, null);
					}
				});
			} else {
				mini.alert("请选中需要删除的数据行", "提示", null);
			}
		}
	</script>

</html>